
import os
import pickle

__author__ = 'B0bY'


class PickleLoader:
    es_id = None
    es_en = None
#    ne_id = None
    ne_per_id = None
    ne_org_id = None
    ne_loc_id = None
    ne_per_en = None
    ne_org_en = None
    ne_loc_en = None
#    ne_en = None

    def __init__(self):
        dir = os.path.dirname(__file__) + "/"
        #dir = ""
        #Load pickles sentiment
#        self.es_en = self.load_pickle_es(dir + 'pickles/es_chunker_en.pickle')
        #self.es_id = self.load_pickle_es('pickles/es_chunker_in.pickle')
#        self.es_id = self.load_pickle_es(dir + 'pickles/es_chunker_id.pickle')
        #Load pickles ner
#        self.ne_en = self.load_pickle_ne('pickles/ne_chunker_en.pickle')
#        self.ne_id = self.load_pickle_ne('pickles/ne_chunker_id.pickle')
        self.ne_per_en = self.load_pickle(dir + 'binary/ne_per_en.pickle')
        self.ne_org_en = self.load_pickle_ne(dir + 'binary/ne_org_en.pickle')
        self.ne_loc_en = self.load_pickle_ne(dir + 'binary/ne_loc_en.pickle')
#        self.ne_per_en = self.load_pickle_ne(dir + '/pickles/ne_per_en.pickle')
#        self.ne_org_en = self.load_pickle_ne(dir + '/pickles/ne_org_en.pickle')
#        self.ne_loc_en = self.load_pickle_ne(dir + '/pickles/ne_loc_en.pickle')

    def load_pickle_es(self,filename):
        pkl_file = open(filename, 'rb')
        es = pickle.load(pkl_file)
        pkl_file.close()
        return es

    def load_pickle_ne(self,filename):
        cp = PickleLoader.load_pickle(filename)
        return cp
    
    @staticmethod
    def load_pickle(filename):
        pkl_file = open(filename, 'rb')
        cp = pickle.load(pkl_file)
        pkl_file.close()
        return cp


if __name__ == "__main__":
    print __package__
    print __file__
